#output how much time each task used in CPU 0
#		sched_info_switch(prev, next);
#		perf_event_task_sched_out(prev, next);
#		rq->nr_switches++;
#		rq->curr = next;
#		++*switch_count;
#		context_switch(rq, prev, next); /* unlocks the rq */

tvariable $first=1
tvariable $begin
tvariable $pid

#Must before context_switch
list schedule
trace 5821 if ($cpu_id==0 && $first == 1)
#trace 4282 if ($cpu_id==0 && $first == 1)
action
  teval $begin = $cooked_rdtsc
  teval $first = 0
end

list schedule
trace 5821 if ($cpu_id==0 && $first == 0)
#trace 4282 if ($cpu_id==0 && $first == 0)
action
  teval $pid = (uint64_t)((struct task_struct *)$current_task)->pid
  collect $pid
  teval $begin = $cooked_rdtsc - $begin
  collect $begin
  teval $begin = $cooked_rdtsc
  collect ((struct task_struct *)$current_task)->comm
end

trace do_exit if ($cpu_id==0 && $first == 0)
action
  teval $pid = (uint64_t)((struct task_struct *)$current_task)->pid
  collect $pid
  teval $begin = $cooked_rdtsc - $begin
  collect $begin
  collect ((struct task_struct *)$current_task)->comm
  teval $first = 1
end
